<template>
  <view class="background bd">
    <view class="content">
      <view
        class="card bd1 t1"
        v-for="(item, index) in list"
        @tap="goPage(item.id)"
        style="text-align: left"
      >
        <p style="margin-left: -60rpx; font-weight: 500" class="t1">
          {{ title }}
        </p>
        答题时间：{{ item.createTimes }} 最终得分：{{ item.score }}分
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      id: "", //options传入的id
      title: "",
      list: "",
    };
  },
  onLoad(options) {
    //console.log(options)
    this.id = options.id || this.$store.state.idxs;
    this.title = options.name;
    this.findAnswer();
  },
  onReady() {
    // this.getUiStyle();
  },
  methods: {
    getUiStyle() {
      var style = plus.navigator.getUiStyle();
      if ("dark" == style) {
        console.log("当前为暗黑模式");
        uni.setTabBarStyle({
          backgroundColor: "#1B1C1E",
        });
        uni.setNavigationBarColor({
          frontColor: "#ffffff",
          backgroundColor: "#1B1C1E",
          animation: {
            duration: 400,
            timingFunc: "easeIn",
          },
        });
      } else {
        console.log("当前为普通模式");
      }
    },
    findAnswer() {
      let self = this;
      uni.showLoading({
        title: "加载中",
        mask: true,
      });
      setTimeout((s) => {
        uni.hideLoading();
      }, 5000);
      this.config
        .post("/evaluating/getSubjectOrRecords", {
          id: this.id,
          isRepeat: 0,
        })
        .then((res) => {
          uni.hideLoading();
          if (res.data.code === 200) {
            self.list = res.data.data.data;
          } else {
            if (res.data.code == "-201") {
              self.config.handleError(res.data);
            } else {
              uni.showToast({
                title: self.config.handleError(res.data),
                icon: "none",
              });
            }
          }
        });
    },
    goPage(id) {
      //console.log(id)
      uni.navigateTo({
        url:
          "/pages/main/child/archives/evaluation-results?id=" +
          id +
          "&oldId=" +
          this.id,
      });
    },
  },
};
</script>

<style lang="less" scoped>
page {
  background-color: #f9f9f9;
}

.title {
  width: 100%;
  padding: 30upx 80upx;

  .text {
    display: flex;
    justify-content: center;
    align-items: center;
    // width: 100%;
    height: 60upx;
    background-image: url(../../../../static/img/title.png);
    background-size: 100% 100%;
    font-size: 30upx;
    color: #ffffff;
  }
}

.content {
  width: 100%;
  padding: 0 25upx;
  margin-top: 30rpx;

  .card {
    -moz-box-shadow: 0px 0px 10px 0px rgba(28, 28, 28, 0.09);
    -webkit-box-shadow: 0px 0px 10px 0px rgba(28, 28, 28, 0.09);
    box-shadow: 0px 0px 10px 0px rgba(28, 28, 28, 0.09);
    background-color: #ffffff;
    border-radius: 15upx;
    padding: 20upx;
    text-indent: 2em;
    font-size: 30upx;
    font-weight: 200;
    line-height: 60upx;
    color: #222222;
    margin-top: 20rpx;
  }
}

@media (prefers-color-scheme: closedark) {
  .bd {
    background-color: #1b1c1e !important;
    margin-top: -16px;
    height: 100vh;
    padding-top: 20px;
  }

  .bd1 {
    background-color: #38383c !important;
  }

  .t1 {
    color: #ccc !important;
  }
}
</style>‰
